<script>
import { tileLayer } from 'leaflet';
export default {
	name: 'LTileLayer',
	inject: ['getMap'],
	props: ['url', 'labelurl', 'option'],
	data() {
		return {
			map: null,
			layer: null,
			labelLayer: null,
		};
	},

	mounted() {
		let vm = this;
		vm.getMap(map => {
			vm.map = map;
			vm.addLayer();
		});
	},
	methods: {
		addLayer() {
			let vm = this;
			
			vm.layer = tileLayer(this.url, this.option);
			vm.layer.addTo(this.map);

			if (this.labelurl) {
				vm.labelLayer = tileLayer(this.labelurl, this.option);
				vm.labelLayer.addTo(this.map);
			} 
		},
	},
	render(h) {
		return h;
	},
};
</script>
